package com.gec.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gec.mapper.UserMapper;
import com.gec.pojo.User;
import com.gec.service.UserService;
@Service
public class UserServiceImpl implements UserService{
	
	@Autowired
	UserMapper userMapper;

	@Override
	public User userLogin(String loginName, String password) {
		return userMapper.userLogin(loginName,password);
	}

	@Override
	public int userRegister(String name, String password, String email) {
		return userMapper.userRegister(name, password, email);
	}

	@Override
	public User getUserByName(String name) {
		return userMapper.getUserByName(name);
	}

	@Override
	public void update(String name, String email, String sex, int age, int stunum,String origin) {
		userMapper.updateData(name,email,sex,age,stunum,origin);
		userMapper.updateArticle(name,origin);
		userMapper.updateReply(name,origin);
	}

	@Override
	public void expUP(int i,String name) {
		userMapper.expUP(i,name);
	}

	@Override
	public void LVcheck(int exp,int lv,String name) {
		int expMax = 100;
		for(int i = lv;i > 0;i--) {
			expMax *= 2;
		}
		if(exp >= expMax) {
			lv++;
		}
		userMapper.LvUp(lv,name);
	}

}
